import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop019_添加属性信息"
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,"商品管理","商品属性","属性分组")
# 1.点击“添加属性”按钮，编写属性分组“好好学习”，属性类型“下拉”，属性名称“天天向上”，排序“255”。
firefox.find_element_by_xpath("//a[@class='btn btn-small btn-primary']").click()
firefox.find_element_by_xpath("//input[@id='attribute_group_name']").send_keys("好好学习,天天向上")
firefox.find_element_by_xpath("//input[@id='attribute_group_sort']").clear()
firefox.find_element_by_xpath("//input[@id='attribute_group_sort']").send_keys("1")
time.sleep(4)
#保存属性信息
firefox.find_element_by_xpath('//button[@type="submit"]').click()
#添加属性值
DBshopEnterMenu3(firefox,"商品管理","商品属性","属性")
firefox.find_element_by_link_text('添加属性').click()
from selenium.webdriver.support.select import Select
s1=Select(firefox.find_element_by_id("attribute_group_id"))
s1.select_by_visible_text("好好学习")
s2=Select(firefox.find_element_by_id("attribute_type"))
s2.select_by_visible_text("下拉")
firefox.find_element_by_id("attribute_name").send_keys("天天向上")
# 2.点击“保存属性信息”按钮，保存成功。
firefox.find_element_by_xpath("//button[@class='btn btn-small btn-primary']").click()
try:
    firefox.find_element_by_xpath("//td[contains(.,'天天向上')]")
    writeLog("%s测试通过"%testCase)
except:
    writeLog("%s测试失败"%testCase)
    getPhoto(firefox)
firefox.quit()